async function updata_data(data_arr) {
    for(let data of data_arr){
        for(let key in data){
            if(data[key]===""||data[key]==="暂无"){
                data[key] = null;
            }
        }
    }
    let result = JSON.parse(window.android_road_data.updata_data(JSON.stringify(data_arr)));
    if(result.error){
        throw new Error(result.error);
    }
    return result.data;
}

async function check_data(road_part_id) {
    let result = JSON.parse(window.android_road_data.check_data(road_part_id));
    if(result.error){
        throw new Error(result.error);
    }
    return result.data;
}

async function add_data(obj) {
    for(let i = 0;i<obj.features.length;i++){
        for(let key in obj.features[i].properties){
            if(obj.features[i].properties[key] === '暂无'||obj.features[i].properties[key] === 'null'){
                obj.features[i].properties[key] = null;
            }
        }
    }
    let result = JSON.parse(window.android_road_data.add_data(JSON.stringify(obj)));
    if(result.error){
        throw new Error(result.error);
    }
    return result.data;
}

async function delete_data(road_part_id_arr) {
    let result = JSON.parse(window.android_road_data.delete_data(JSON.stringify(road_part_id_arr)));
    if(result.error){
        throw new Error(result.error);
    }
    return result.data;
}

async function get_all_data() {
    let result = JSON.parse(window.android_road_data.get_all_data());
    if(result.error){
        throw new Error(result.error);
    }
    return result.data;
}

async function get_filte_data_from_server(filter_obj) {
    for(let key in filter_obj.filte_checkbox_obj){
        filter_obj.filte_checkbox_obj[key] = Array.from(filter_obj.filte_checkbox_obj[key]);
    }
    let result = JSON.parse(window.android_road_data.get_filte_data(JSON.stringify(filter_obj)));
    if(result.error){
        throw new Error(result.error);
    }
    return result.data;
}
